//
// Created by hjie on 23-9-17.
//

#pragma once

#include "./../../loop_event/loop_event_define.h"
#include "./../stun_message.h"
#include "define.h"
#include <cstdint>
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "config.h"
#include "thread_pool.h"

class MessageProcess;
class TurnServer;
class Session;

class TurnServer
{
public:
    explicit TurnServer(LoopEvent * loop_event);
    ~TurnServer();
    int Listen(int port);
public:
    void OnMessage(UdpPacket * packet);
    void OnMessageThreadPool(UdpPacket * packet);
    void ProcessStunMessage(UdpBufferPacket & packet, StunMessage & message);
    void OnTimer();
public:
    LoopEvent * m_loop_event;
    UdpServer * m_udp_server;
    int m_listen_port;
public:
    std::shared_ptr<StunConfig>     m_config;
    std::shared_ptr<MessageProcess> m_process_ptr;
    std::shared_ptr<ThreadPoolManager> m_thread_manager;
    std::map<std::string, std::shared_ptr<Session>> m_session_map;
};